﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Mighty.Lib.Document
{
    public class DefaultSaveProvider : ISaveProvider
    {
        #region ISaveProvider Members

        public DefaultSaveProvider() { }

        public bool Save(Dictionary<string, object> saveParams)
        {
            FileStream file = new FileStream((string)saveParams["SaveFilePath"], FileMode.Create, FileAccess.Write);
            StreamWriter writer = new StreamWriter(file);
            List<string> list = (List<string>)saveParams["DocumentContents"];
            list.ForEach((s) =>
            {
                writer.WriteLine(s);
                writer.Flush();
            });
            file.Flush();
            file.Close();
            return true;
        }

        #endregion
    }
}
